package com.heima.feigns.fallback;

import com.heima.feigns.UserFeign;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author huan
 * @serial 每天一百行, 致敬未来的自己
 * @Description
 */
@Slf4j
@Component
public class UserFeignFallback implements FallbackFactory<UserFeign> {

    @Override
    public UserFeign create(Throwable throwable) {
        throwable.printStackTrace();
        return id -> {
            log.error("查询用户信息 远程调用出错啦 ~~~ !!!! {} ", throwable.getMessage());
            return ResponseResult.errorResult(AppHttpCodeEnum.REMOTE_SERVER_ERROR);
        };
    }
}

